package cn.shop.admin.component.withdraw;

import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;

/**
 * 提现上下文
 *
 * @author jzw
 * @since 2021-11-11 10:13
 */
@Component
public class WithdrawContext {

	@Resource
	private Set<WithdrawStrategy> strategy;

	private static Map<Integer, WithdrawStrategy> strategyMap;

	@PostConstruct
	public void init() {
		strategyMap = strategy.stream().collect(Collectors.toMap(WithdrawStrategy::getType, a -> a));
	}

	public static WithdrawStrategy getInstance(Integer type) {
		return strategyMap.get(type);
	}

}
